﻿using System.Collections;
using UnityEngine;
using UniRx;

public abstract class SkillEffectBase : USaBehaviour
{
    private ParticleSystem m_Particle;
    public ParticleSystem particle => m_Particle ?? (m_Particle = GetComponent<ParticleSystem>());


    private Timer.Simple m_Timer = new Timer.Simple();
    private SkillBase m_Skill;


    private void Awake()
    {
        m_Timer.onFinish.Subscribe(_ =>
        {
            m_Skill.effectPool.Return(this);
        });
    }

    private void OnEnable()
    {
        m_Timer.Start(particle.main.duration, this);
    }

    private void OnDestroy()
    {
        m_Timer.ShutDown();
    }

    public void SetData(SkillBase skill)
    {
        m_Skill = skill;
    }
}